#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2021/3/21 22:45
# @Author  : Hbber
# @Version : 0.0.0
# @File    : test.py
# @Software: PyCharm
# @Org     : AirCas
# @Describe: 

# @Last Modify Time          @Version        @Description
# --------------------       --------        -----------
# 2021/3/21 22:45            0.0.1           None

# 
import socket
import sys
import time
import json

def get_timestamp13():
    return round(time.time()*1000)

def socket_client():
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect(('10.0.0.222', 6666))
    except socket.error as msg:
        print(msg)
        sys.exit(1)
    print(s.recv(4096))  # 目的在于接受：Accept new connection from (...
    t_start = get_timestamp13()
    while 1:
        r_data = json.loads(s.recv(4096))
        delt_t = r_data["timestamp"] - t_start
        t_start = r_data["timestamp"]
        print('delt_t:{0}ms'.format(delt_t))


if __name__ == '__main__':
    socket_client()
